// Wrong Answer

#include <iostream>
#include <stdio.h>
#include <deque>
#include <vector>
#include <string.h>
#include <algorithm>

using namespace std;

vector< vector<int> > adj;
deque<int> q;
int n, result;

void init()
{
	result = 0;
	adj.resize(n);
	for (int i = 0; i < n; i++) adj[i].resize(0);
}

void BFS()
{
	vector<bool> visited(n, false);
	deque<int> q0;
	deque<int> q1;

	q0.resize(0);
	for (int u = 0; u < n; u++) 	
		if (adj[u].size() == 1)
		{
			q0.push_back(u);
			visited[u] = true; 
		}

	while (true)
	{
		if (q0.empty()) break;

		q1.resize(0);
		while (!q0.empty())
		{
			int u = q0.front();
			q0.pop_front();
			
			for (int i = 0; i < (int) adj[u].size(); i++) 
			{
				int v = adj[u][i];
				if (!visited[v])
				{
					q1.push_back(v);
					visited[v] = true;
//					cout << "den " << v << endl;
				}
			}
		}

		result += q1.size();

		q0.resize(0);
		while (!q1.empty())
		{
			int u = q1.front();
			q1.pop_front();

			for (int i = 0; i < (int) adj[u].size(); i++)
			{
				int v = adj[u][i];
				if (!visited[v])
				{
					q0.push_back(v);
					visited[v] = true;
//					cout << "trang " << v << endl;
				}
			}
		}
	}
}


int main()
{
	while (cin >> n)
	{
		init();
		for (int i = 0; i < n; i++) 
		{
			int m, k;
			scanf ("%d:(%d)", &m, &k);
			for (int j = 0; j < k; j++)
			{
				int p;
				scanf("%d", &p);
				adj[m].push_back(p);
				adj[p].push_back(m);
			}
			scanf("\n");
		}

		if (n == 1 || n == 2) 
		{
			if (n == 1) cout << 0 << endl;
			else cout << 1 << endl;
			continue;
		}

		BFS();
		cout << result << endl;	
	}
		
	return 0;
}
